﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class editPhone : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "PhoneNuber_RegionCode",
                table: "Users",
                newName: "Phone_RegionCode");

            migrationBuilder.RenameColumn(
                name: "PhoneNuber_Number",
                table: "Users",
                newName: "Phone_Number");

            migrationBuilder.RenameColumn(
                name: "PhoneNuber_RegionCode",
                table: "UserLoginHistories",
                newName: "Phone_RegionCode");

            migrationBuilder.RenameColumn(
                name: "PhoneNuber_Number",
                table: "UserLoginHistories",
                newName: "Phone_Number");

            migrationBuilder.AlterColumn<string>(
                name: "passwordHash",
                table: "Users",
                type: "varchar(127)",
                unicode: false,
                maxLength: 127,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(127)",
                oldUnicode: false,
                oldMaxLength: 127)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "Phone_RegionCode",
                table: "Users",
                newName: "PhoneNuber_RegionCode");

            migrationBuilder.RenameColumn(
                name: "Phone_Number",
                table: "Users",
                newName: "PhoneNuber_Number");

            migrationBuilder.RenameColumn(
                name: "Phone_RegionCode",
                table: "UserLoginHistories",
                newName: "PhoneNuber_RegionCode");

            migrationBuilder.RenameColumn(
                name: "Phone_Number",
                table: "UserLoginHistories",
                newName: "PhoneNuber_Number");

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "passwordHash",
                keyValue: null,
                column: "passwordHash",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "passwordHash",
                table: "Users",
                type: "varchar(127)",
                unicode: false,
                maxLength: 127,
                nullable: false,
                oldClrType: typeof(string),
                oldType: "varchar(127)",
                oldUnicode: false,
                oldMaxLength: 127,
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
